package com.shujujiegou.无权无向图.搜索.实现深度优先搜索的栈;

public class Queue {
    private final int SIZE = 20;
    private int[] queryArray;
    private int front;
    private int rear;
    private int currentSize;

    public Queue() {
        this.queryArray = new int[SIZE];
        this.front = 0;
        this.rear = -1;
    }

    public void insert(int data) {
        if(this.currentSize == SIZE) {
            return;
        }
        if(this.rear == (SIZE - 1)) {
            this.rear = -1;
        }
        this.queryArray[++rear] = data;
        this.currentSize++;
    }

    public int remove() {
        if(this.currentSize <= 0) {
            return -1;
        }

        int temp = this.queryArray[this.front];
        this.front ++;
        if(this.front == SIZE) {
            this.front = 0;
        }

        this.currentSize --;
        return temp;
    }

    public boolean isEmpty() {
        return this.currentSize <= 0 ? true : false;
    }
}
